Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: structured logging (JSON) #5118

Merged
merged 7 commits into from
Sep 24, 2024

Conversation

SapphicCode
Copy link
Contributor

@SapphicCode SapphicCode commented Sep 19, 2024

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Implements structured logging, as requested by #5107.
Resolves #5107

This feature can be enabled by using the environment variable UPTIME_KUMA_LOG_FORMAT set to json.

This PR also incorporates the work of #4391 and #4392 (with minor fixes to both as per the linter), for the feature itself I would direct your attention to commit 3e922be.

Closes #4391
Closes #4392

Type of change

Please delete any options that are not relevant.

  • User interface (UI)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Before

Code - 2024-09-19 10 24 23

After

Code - 2024-09-19 10 26 47

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

…log`

Co-authored-by: Frank Elsinga <[email protected]>
Closes: louislam#4391

Squashed commit of the following:

commit 828d2a7
Merge: 10f771c dd75890
Author: Frank Elsinga <[email protected]>
Date:   Fri Sep 13 22:51:25 2024 +0800

    Merge branch 'master' into deprecations

commit 10f771c
Author: Frank Elsinga <[email protected]>
Date:   Thu Jan 18 22:36:12 2024 +0100

    formatting fixes

commit d737b19
Author: Frank Elsinga <[email protected]>
Date:   Thu Jan 18 21:27:30 2024 +0100

    migrated all settings to use the `Settings` class

commit c5e26e9
Author: Frank Elsinga <[email protected]>
Date:   Thu Jan 18 21:04:44 2024 +0100

    removed the deprecated logging functionality
Co-authored-by: Frank Elsinga <[email protected]>
Closes: louislam#4392

Squashed commit of the following:

commit 75c4c35
Merge: 14e3c3c dd75890
Author: Frank Elsinga <[email protected]>
Date:   Fri Sep 13 22:46:21 2024 +0800

    Merge branch 'master' into unified-logging-infrastructure

commit 14e3c3c
Merge: d622dfb c919d2c
Author: Frank Elsinga <[email protected]>
Date:   Mon Jun 3 16:00:56 2024 +0200

    Merge branch 'master' into unified-logging-infrastructure

commit d622dfb
Author: Frank Elsinga <[email protected]>
Date:   Thu Jan 18 22:31:10 2024 +0100

    unified our logging infrastructure
Includes a slight refactor in the console logging section, to achieve an unformatted output and reduce complexity.

Resolves: louislam#5107
@SapphicCode SapphicCode changed the title feat: structured logging feat: structured logging (JSON) Sep 19, 2024
Resolves the following trace:

Trace: TypeError: Cannot convert object to primitive value
    at res.end (<snip>/uptime-kuma/server/modules/apicache/apicache.js:308:64)
    at ServerResponse.send (<snip>/uptime-kuma/node_modules/express/lib/response.js:233:10)
    at ServerResponse.json (<snip>/uptime-kuma/node_modules/express/lib/response.js:279:15)
    at module.exports.sendHttpError (<snip>/uptime-kuma/server/util-server.js:806:25)
    at <snip>/uptime-kuma/server/routers/status-page-router.js:58:9
    at process.unexpectedErrorHandler (<snip>/uptime-kuma/server/server.js:1858:13)
    at process.emit (node:events:519:28)
    at emitUnhandledRejection (node:internal/process/promises:250:13)
    at throwUnhandledRejectionsMode (node:internal/process/promises:385:19)
    at processPromiseRejections (node:internal/process/promises:470:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)
CommanderStorm

This comment was marked as outdated.

@CommanderStorm CommanderStorm added area:core issues describing changes to the core of uptime kuma type:enhance-existing feature wants to enhance existing monitor pr:please address review comments this PR needs a bit more work to be mergable labels Sep 23, 2024
Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the refactoring/logging improvement! 🎉

Note

This PR is part of the v2.0 merge window => see #4500 for the bugs that need to be addressed before we can ship this release ^^

All changes in this PR are small and uncontroversial ⇒ merging with junior maintainer approval

@CommanderStorm CommanderStorm merged commit b287a25 into louislam:master Sep 24, 2024
18 checks passed
@CommanderStorm CommanderStorm added this to the 2.0.0 milestone Sep 24, 2024
@louislam louislam mentioned this pull request Oct 7, 2024
1 task
@louislam louislam added releaseblocker blocking bugs encountered with a new release question Further information is requested and removed question Further information is requested releaseblocker blocking bugs encountered with a new release labels Oct 7, 2024
@louislam
Copy link
Owner

louislam commented Oct 8, 2024

I think it also breaks the hide logging feature.

louislam added a commit that referenced this pull request Oct 8, 2024
notifyDays = [ 7, 14, 21 ];
await Settings.set("tlsExpiryNotifyDays", notifyDays, "general");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not presented in the old code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Yea, the first time of setting the setting should not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@louislam louislam removed this from the 2.0.0 milestone Oct 8, 2024
@SapphicCode
Copy link
Contributor Author

I think it also breaks the hide logging feature.

I'm not sure how that's possible, those lines weren't modified at all...

@CommanderStorm
Copy link
Collaborator

+1 this does not break the hide log feature.

#5157 is a pretty unfortunate thing, but I don't think the whole console logging filtering code should be executed in the browser.
We should remove that part (in a different PR).

I think pushing this is not nessesary, but don't want to fight about this
=> lets push this for one release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core issues describing changes to the core of uptime kuma pr:please address review comments this PR needs a bit more work to be mergable type:enhance-existing feature wants to enhance existing monitor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to configure UPTIME_KUMA_LOG_FORMAT: json or text
3 participants